{php $layout_left = true;}

<div class="sidebar bg-black">
    <div class="sidebar-top col-12 no-gutters p-0">
        <nav class="navbar navbar-dark">
            <div class="navbar-brand">
                <div class="navbar-icon rounded mr-2">
                    <img src="/logo.png" class="rounded-circle w-100 h-100"/>
                </div>
                <div class="navbar-title">
                    <span>{:\Sys('site_name')}</span> <br/>
                    <span class="text-light" style="font-size: 12px;">平台后台</span>
                </div>
            </div>
        </nav>
    </div>
    
    <div class="slidebar-menu accordion" id="accordion">
        
        <div class="card left-menu bg-jasper">
            <div class="card-header p-1">
                <a href="javascript:void(0);" class="btn btn-link w-100 text-left text-gray" data-toggle="collapse" data-target="#cms">
                    <i class="fa fa-wpforms"></i><span>内容</span>
                </a>
            </div>
            <div id="cms" class="collapse" data-parent="#accordion">
                <div class="card-body p-0">
                    <div class="list-group">
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/aboutus/index">关于我们</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/article/index">文章管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/column/index">栏目管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/banner/index">轮播管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/ads/index">广告管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/hotword/index">热词管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/link/index">友链管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/friend/index">伙伴管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/comment/index">留言管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/event/index">公告管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/cms/tag/index">标签管理</a>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="card left-menu bg-jasper">
            <div class="card-header p-1">
                <a href="javascript:void(0);" class="btn btn-link w-100 text-left text-gray" data-toggle="collapse" data-target="#user">
                    <i class="fa fa-user-circle-o"></i><span>用户</span>
                </a>
            </div>
            <div id="user" class="collapse" data-parent="#accordion">
                <div class="card-body p-0">
                    <div class="list-group">
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/user/index">用户管理</a>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="card left-menu bg-jasper">
            <div class="card-header p-1">
                <a href="javascript:void(0);" class="btn btn-link w-100 text-left text-gray" data-toggle="collapse" data-target="#system">
                    <i class="fa fa-cog"></i><span>系统</span>
                </a>
            </div>
            <div id="system" class="collapse" data-parent="#accordion">
                <div class="card-body p-0">
                    <div class="list-group">
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/system/config">参数配置</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/system/password">修改密码</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/system/system">系统设置</a>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="card left-menu bg-jasper">
            <div class="card-header p-1">
                <a href="javascript:void(0);" class="btn btn-link w-100 text-left text-gray" data-toggle="collapse" data-target="#rbac">
                    <i class="fa fa-shield"></i><span>权限</span>
                </a>
            </div>
            <div id="rbac" class="collapse" data-parent="#accordion">
                <div class="card-body p-0">
                    <div class="list-group">
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/rbac/route/index">权限绑定</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/rbac/role/index">角色管理</a>
                        <a class="list-group-item bg-black text-gray"
                            href="/admin/rbac/user/index">账户管理</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    
    $(function () {
        $(".slidebar-menu").css('min-height', (document.documentElement.clientHeight - 40) + 'px');
        $(".sidebar-toggle").click(function () {
            $(".sidebar").toggleClass('collapsed');
            cache('sidebar-collapse', !cache('sidebar-collapse'));
        });
    });
    
    $('#accordion').on('hide.bs.collapse', function () {
        if ($(".sidebar").hasClass('collapsed')) {
            return e.preventDefault();
        }
    });
    
    $('#accordion').on('show.bs.collapse', function () {
        if ($(".sidebar").hasClass('collapsed')) {
            return e.preventDefault();
        }
    });
    
    if (!cache('sidebar-collapse')) {
        $(".sidebar").removeClass('collapsed');
        cache('sidebar-collapse', false);
    } else {
        $(".sidebar").addClass('collapsed');
    }
    
    var console_menu = cache('console_menu');
    if (console_menu) {
        var $menu = $('a[href="' + console_menu + '"]');
        $menu.addClass('active');
        $menu.parent().parent().parent().addClass('show');
    }
    
    $("a").click(function (e) {
        var href = $(this).prop('href');
        var target = $(this).prop('target');
        
        if (!href || target) {
            return true;
        }
        
        var url = parseUrl(href);
        
        var src = url.relative.replace('/admin/index/index', '');
        src = src.replace('/index/index', '');
        src = src.replace('#', '');
        
        if (src) {
            
            if ($(this).parent().parent().parent().parent().hasClass('left-menu bg-jasper')) {
                $(".left-menu bg-jasper .list-group-item").removeClass('active');
                $(this).addClass('active');
                
                // 缓存当前激活菜单
                cache('console_menu', src, 60 * 60);
            } else {
                // 清理当前激活菜单
                cache('console_menu', '');
            }
            
        }
    });
</script>
<div class="wrapper">
    <nav class="navbar navbar-dark col-12">
        <div class="navbar-brand">
            <div class="sidebar-toggle">
                <i class="fa fa-bars text-white"></i>
            </div>
            
            <div class="nav-item">
                <a class="nav-link text-white" href="/admin/index/index">控制台</a>
            </div>
            
            <div class="nav-item">
                <a class="nav-link text-white" href="{:\Sys('site_root')}" target="_blank">网站首页</a>
            </div>
            
        </div>
        
        <form class="form-inline">
            
            <div class="mr-3 text-white">
                <div class="font-weight-bold">{$authed_user['nickname']}</div>
                <div>{$authed_user['username']}</div>
            </div>
            
            <a class="btn btn-outline-light" href="{:$this->createUrl('login', 'logout')}">退出</a>
        </form>
    </nav>
    <div class="main col-12 p-3">